<template>
  <div class="detail">
    <detail-banner :sightName="sightName" :bannerImg="bannerImg" :bannerImgs="gallaryImgs" />
    <detail-header />
    <detail-list :list="list" />
    <div class="content"></div>
  </div>
</template>

<script>
import DetailBanner from './components/banner.vue'
import DetailHeader from './components/header.vue'
import DetailList from './components/list.vue'
import axios from 'axios'
export default {
  name: 'Detail',
  components: {
    DetailBanner,
    DetailHeader,
    DetailList
  },
  data () {
    return {
      sightName: '',
      bannerImg: '',
      gallaryImgs: [],
      list: []
    }
  },
  mounted () {
    console.log('detail mounted')
    this.getData()
  },
  activated () {
  },
  methods: {
    getData () {
      // axios.get('/api/detail.json?id=' + this.$route.params.id).then((res) => {
      axios.get('/api/detail.json', {
        params: {
          id: this.$route.params.id
        }
      }).then((res) => {
        if (res.status === 200) {
          if (res.data.ret) {
            const data = res.data.data
            this.sightName = data.sightName
            this.bannerImg = data.bannerImg
            this.gallaryImgs = data.gallaryImgs
            this.list = data.categoryList
          }
        }
      })
    }
  }
}
</script>

<style lang="stylus" scoped>
  .content
    height 50rem
</style>
